import Shop from '../common/bean/Shop'
import axios from '@ohos/axios'
class ShopService2{
  baseURL:string='http://192.168.0.8:3000'
  page:number=1

  getShopList():Promise<Shop[]>{
    return new Promise((resolve,reject)=>{
      //1 发送请求
      axios.get(
        `${this.baseURL}/shops?_page=${this.page}&_limit=3`,

      ).then(
        resp=>{
          if(resp.status===200){
            console.log('查询商铺成功',JSON.stringify(resp.data))
            resolve(resp.data)
          }
          else{
            console.log('查询商铺信息失败！error:',JSON.stringify(resp))
            reject('查询商铺失败！')
          }
        }
      ).catch(error=>{
        console.log('查询商铺信息失败！error:',JSON.stringify(error))
        reject('查询商铺失败！')
      })
    })
  }
}

const shopService=new ShopService2()
export default shopService as ShopService2